$(document).ready(function(){
	
	// Uploadify's options
	$('#model-file-upload').uploadify({
		'uploader'  : 'inc/uploadify.swf',
		'script'    : 'process/upload_models.php',
		'cancelImg' : 'css/img/cancel.png',
		'buttonImg'	: 'css/img/folder_add.png',
		'folder'    : 'data/models',
		'auto'      : false,
		'multi'		: true,
		'wmode'		: 'transparent',
		'height'	: '16',
		'fileExt'	: '*.odt',
		'fileDesc'	: 'Fichiers ODT (.ODT)',
		'onAllComplete'	: function(event,data){
			location.reload();
		}
	});
	
	// Case: deleting a model
	$('a.delete-doc').click(function(){
		var e = $(this);
		$.ajax({
			type:	'POST',
			url:	'process/model_delete.php',
			data:	'id='+e.attr('href'),
			success: function(msg){
				if (msg != 'OK')
					alert(msg);
				else
					e.parent().parent().remove();
			}
		});
		return false;
	});
});